<?php
/**
 * ShopEx licence
 *
 * @copyright  Copyright (c) 2005-2010 ShopEx Technologies Inc. (http://www.shopex.cn)
 * @license  http://ecos.shopex.com/license/gpl GPL License
 */
 
class tbdata_ctl_default extends tbdata_controller{
	function index(){
		$cat_model = $this->app->model('cats');
		$cat_list_grade_1 = $cat_model->getList('*',array('products_download_time|than'=>0,'parent_cid'=>0,'disabled'=>'false'),0,-1);
		foreach($cat_list_grade_1 as $cat){
			$_cat_list_grade_1[$cat['cid']] = $cat;
			$parent_cid[] = $cat['cid'];
		}
		$cat_list_grade_2 = $cat_model->getList('*',array('parent_cid'=>$parent_cid,'disabled'=>'false'),0,-1);
		$parent_cid = array();
		foreach($cat_list_grade_2 as $cat){
			$_cat_list_grade_2[$cat['cid']] = $cat;
			$parent_cid[] = $cat['cid'];
		}

		$cat_list_grade_3 = $cat_model->getList('*',array('parent_cid'=>$parent_cid,'disabled'=>'false'),0,-1);

		foreach($cat_list_grade_3 as $cat){
			$_cat_list_grade_2[$cat['parent_cid']]['children'][$cat['cid']] = $cat;
		}

		foreach($_cat_list_grade_2 as $cat){
			$_cat_list_grade_1[$cat['parent_cid']]['children'][$cat['cid']] = $cat;
		}
		#print_r($_cat_list_grade_1);
		$this->pagedata['cat_list'] = $_cat_list_grade_1;

		$this->output('cats/index.html');
	}
    function index2(){

		$this->object = kernel::single('tbdata_api_amazon');
	
		$a = $this->object->get_items();
		print_r($a);exit;
		/*$cats = $object->get_std_cats(14);
		print_r($cats);exit;
		*/
		
		/*
		$params['method'] = 'taobao.itemprops.get';
		$params['cid'] = 1403;
		$params['fields'] = 'pid,is_input_prop,parent_pid,parent_vid,name,must,multi,prop_values,is_key_prop,is_sale_prop,is_item_prop,status,sort_order,child_template,is_allow_alias';
		$a = $object->get_data($params);
		print_r($a);exit;
		*/
		
		/*
		$params['method'] = 'taobao.itemprops.get';
		$params['cid'] = 1403;
		$params['child_path'] = '20000:10752';
		$params['fields'] = 'pid,is_input_prop,parent_pid,parent_vid,name,must,multi,prop_values,is_key_prop,is_sale_prop,is_item_prop,status,sort_order,child_template,is_allow_alias';
		$a = $object->get_data($params);
		print_r($a);exit;
		*/
		
		/*
		$params['method'] = 'taobao.product.get';
		$params['cid'] = 1403;
		$params['child_path'] = '20000:10752;20225:23570';
		#$params['pid'] = '20000';
		#$params['parent_pid'] = '94544809';
		$params['fields'] = 'pid,name,must,multi,prop_values,is_key_prop,is_sale_prop,is_item_prop';
		$a = $object->get_data($params);
		print_r($a);exit;
		*/

		
		$params['method'] = 'taobao.products.search';
		$params['cid'] = 1403;
		$params['page_size'] = 40;
		$params['fields'] = 'product_id,outer_id,created,tsc,cid,cat_name,props,props_str,binds_str,sale_props_str,collect_num,name,binds,sale_props,price,desc,pic_url,modified,product_imgs,product_prop_imgs,status,level,pic_path,vertical_market,customer_props,property_alias';
		$a = $object->get_data($params);
		print_r($a);exit;
		/*
		$params['method'] = 'taobao.product.get';
		$params['cid'] = 1403;
		$params['product_id'] = 132096064;
		$params['fields'] = 'cat_name,props,binds,name,sale_props,price,desc,product_imgs,pic_url,pic_path';
		$a = $object->get_data($params);
		print_r($a);*/
		
    }
    
}